<?php
/*	require "libs/constellation.class.php";
	$constellation = new constellation();
	$hd = $constellation->getHuangdao();
	$hd = addslashes(serialize($hd));

	$today = $constellation->getToday("aries");
	$today = addslashes(serialize($today));
	
	$week = $constellation->getWeekly("aries");
	$week = addslashes(serialize($week));
	
	$month = $constellation->getMonthly("aries");
	$month = addslashes(serialize($month));
	
	$year = $constellation->getYear("aries");
	$year = addslashes(serialize($year));
	
	$yearlove = $constellation->getYear_love("aries");
	$yearlove = addslashes(serialize($yearlove));
	
	$dbhost = "localhost";
	$username = "root";
	$userpass = "root";
	$dbdatabase = "test";*/

/*	$db_connect=mysqli_connect("localhost","root","root", "uutime") or die("Unable to connect to the MySQL!");
	mysqli_set_charset($db_connect,"utf8");
	$time = time();
	mysqli_query($db_connect,"insert into uu_constellation (hd,today,week,month,year,year_love,addtime) values ('{$hd}','{$today}','{$week}','{$month}','{$year}','{$yearlove}',{$time})");
	*/

//解析数据
/*	$result = mysqli_query($db_connect,"SELECT * FROM uu_constellation where id=2");
	$constellation = array();
	$constellation = $row = mysqli_fetch_row($result);
	unset($constellation[0]);
	unset($constellation[7]);
	foreach ($constellation as $k => $v) {
		$constellation[$k] = unserialize($v);
	}
	var_dump($constellation);*/
	


	// mysqli_close($db_connect);
	
	// echo "insert into uu_constellation (hd,today,week,month,year,year_love,addtime) values ('{$hd}','{$today}','{$week}','{$month}','{$year}','{$yearlove}',{$time})";

require "/var/www/html/collection/libs/constellationFormat.class.php";
require "/var/www/html/collection/libs/db.class.php";

class ColloctConstellationInfo{

	private $constellations = array(
		"aries","taurus","gemini","cancer","leo","virgo",
		"libra","scorpio","sagittarius","capricorn","aquarius","pisces",
	);
	private $con;
	private $db;

	function __construct(){
		$this->db = new db();
		$this->con = new constellationFormat();
		$this->db->db_connect();

		
		foreach ($this->constellations as $constellation) {//抓取当天十二个星座的数据并存库
			self::collectConstellation($constellation);
		}
		self::collectIndexHD();

		$this->db->db_close();
	}

	function collectConstellation($constellation){// 每天抓一次
		$result = $this->con->collectConstellation($constellation);
		$this->db->insertConstellation($constellation,$result);
	}

	function collectIndexHD(){//每天抓一次
		$hd = $this->con->collectIndexHD();
		$this->db->insertHD($hd);
	}
}

new ColloctConstellationInfo();

?>
